package com.chen.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chen.dao.StudentMapper;
import com.chen.entity.Student;
import com.chen.service.IStudentService;
import com.sun.xml.internal.ws.addressing.WsaServerTube;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

@Service
public class IStudentServiceImpl extends ServiceImpl<StudentMapper, Student> implements IStudentService {


    @Override
    public Page<Student> getPage(String studentname, Integer pageNum) {
        Page page = new Page(pageNum, 3);
        LambdaQueryWrapper<Student> queryWrapper = new LambdaQueryWrapper<>();
        if (StringUtils.hasText(studentname)) {
            queryWrapper.like(Student::getStudentname, studentname);
        }
        queryWrapper.orderByDesc(Student::getId);
        return this.page(page,queryWrapper);
    }
}
